package com.itheima.module.service;

import com.itheima.module.controller.UserController;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import java.util.Date;

public class App {
    public static void main(String[] args) {
        //负责service对象的容器
        ClassPathXmlApplicationContext context1 = new ClassPathXmlApplicationContext("parent/spring1.xml");



        //创建controller容器

        ClassPathXmlApplicationContext context2 = new ClassPathXmlApplicationContext();
        context2.setParent(context1);
        context2.setConfigLocation("parent/spring2.xml");
        context2.refresh();
        //spring的容器之间可以存在父子关系的






        UserController controller = context2.getBean(UserController.class);





        System.out.println(controller);













        /*WebApplicationContext rootContext =
                WebApplicationContextUtils.getWebApplicationContext(getServletContext());


        getWebApplicationContext(sc(这就是servletContext对象),
                "org.springframework.web.context.WebApplicationContext.ROOT");

        Object attr = servletContext对象.getAttribute("org.springframework.web.context.WebApplicationContext.ROOT");
*/




        new Date().toLocaleString();



    }





}
